package com.mb.app.appused.adapter;

import com.mb.app.appused.R;
import com.mb.app.appused.base.SuperAdapter;
import com.mb.app.appused.greendao.SimpleDataUtil;
import com.mb.app.appused.greendao.database.Histroy;

import android.content.Context;
import android.text.Html;
import android.text.Spanned;

public class ListItemAdapter extends SuperAdapter<Histroy> {
	SimpleDataUtil data;
	public static String DataBaseName="appuse";
	public ListItemAdapter(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	    data=new SimpleDataUtil();
	    data.setupDatabase(context, DataBaseName);
	    setList(data.getList());
		submit();
	}

	@Override
	public int getLayout() {
		// TODO Auto-generated method stub
		return R.layout.view_list_item;
	}

	@Override
	public void setChildView(int position, Histroy data, com.mb.app.appused.base.SuperAdapter.ViewHolder holder) {
		// TODO Auto-generated method stub
		holder.getTextView(R.id.item_lable).setText(getFomatValue(data.getPackageName(), data.getTime()));;
		holder.getTextView(R.id.item_info).setText(data.getType());
		
	}

	
	Spanned getFomatValue(String title, String value) {
		String html = "<big>%s</big><br><small>%s</small>"; // <font
																	// size='12'>%s</font><br><font
																	// size='24'><b>%s</b></font>
		html = String.format(html, title, value);
		return Html.fromHtml(html);
	}
}
